<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			/*
			  1.创建日期对象
			    new Date() 当前时间
			    new Date("2020-02-02") 指定时间
			  2.获取毫秒数
			    Date.now()
			    getTime()
				+new Date()
			  3.String --> Date
			*/
			var date = new Date();
			console.log(date);

			var year = date.getFullYear();
			var month = date.getMonth() + 1;
			var day = date.getDate();
			var hour = date.getHours();
			var minute = date.getMinutes();
			var second = date.getSeconds();

			console.log(year + "年" + month + "月" + day + "日" + hour + "时" + minute + "分" + second + "秒");

			// console.log(date.toLocaleDateString());
			// console.log(date.toLocaleTimeString());

			//-------------------------------------------------------
			//1970, 00:00:00.000
			var t = date.getTime(); //1647309835311(毫秒数)
			// console.log(t);
			//算出2022年3月15号和2008年8月8日相差多少天

			var endTime = Date.now();
			var startTime = new Date('2008-8-8');
			startTime = startTime.getTime();
			var es = endTime - startTime;
			// console.log(es / 1000 / 60 / 60 / 24);

			// console.log(+new Date());

			//------------------------------------------------------------
			var s = "2015-02-31";
			var dt = Date.parse(s);
			console.log(dt);
		</script>
	</head>
	<body>
	</body>
</html>
